home *** CD-ROM | disk | FTP | other *** search
- /* Written by Cookie Monster July 5th, 1993
- *
- * HEY! DON'T BE A LAMER! DON'T RIP CODE!
- * IF YOU USE MY CODE OR MY IDEAS, GREET ME!
- *
- * No warranty is provided at all for any
- * circumstance, and these files are public domain.
- *
- * I will not go into detail about any of this code.
- * If you need help or want more information, then
- * please write me.
- *
- * You can write to Cookie Monster at:
- *
- * Justin Newman
- * PO Box 5724
- * Eugene, OR 97405-0724
- *
- * WE NEED DEMO GROUP MEMBERS! GIVE US A CALL
- * IF YOU WOULD LIKE TO JOIN OUR GROUP!
- *
- * Call The Cookie Jar BBS at 5o3.345.563o
- */
-
- #include <stdlib.h>
- #include <dos.h>
-
- #include "sincos.h"
- #include "text.h"
-
- #define a_sin(a) \
- sintbl[a]
- #define a_cos(a) \
- costbl[a]
-
- #define PointsN 4*4*4
-
- /*
- * each point is defined as x,y,z (p[0]=x,p[1]=y,[2]=z)
- */
-
- int Points[PointsN*3];
-
- int
- main()
- {
- int ScreenWidth,ScreenHeight;
- int PreXadd,PreYadd;
- int PostXadd,PostYadd,PreZadd;
- int Xt,Yt,Zt;
- int X,Y,Z;
- int Xtv,Ytv,Ztv;
- int Xi,Yi,Zi;
- int Xan,Yan,Zan;
- int ScreenX,ScreenY;
- int ThisDI,SaveDI[PointsN];
- int Waited;
- int Char,CharN;
- int done,i,i1,i2,a;
- long temp;
- char c;
-
- /* make a cube vector full of dots */
- for (i=0;i<4;i++) /* z */
- {
- for (i1=0;i1<4;i1++) /* y */
- {
- for (i2=0;i2<4;i2++) /* x */
- {
- Points[i*(16*3)+i1*(4*3)+i2*3+0]=( -40)+i2*30; /* x */
- Points[i*(16*3)+i1*(4*3)+i2*3+1]=( -40)+i1*30; /* y */
- Points[i*(16*3)+i1*(4*3)+i2*3+2]=( -40)+ i*30; /* z */
- }
- }
- }
-
- ScreenWidth=320;
- ScreenHeight=200;
-
- PreXadd=PreYadd=0;PreZadd=-5000;
- PostXadd=ScreenWidth/2+100;
- PostYadd=ScreenHeight/2;
-
- Xan=Yan=Zan=0;
- Xtv=Ytv=Ztv=0;
- Xi=Yi=Zi=0;
-
- Waited=0;
- done=0;
-
- asm mov ax,13h
- asm int 10h
-
- Xi=-1;
- Yi=2;
- Zi=-1;
-
- while (!done)
- {
- asm mov ax,0a000h
- asm mov es,ax
-
- for (i=0;i<PointsN;i++)
- {
- X=Points[i*3+0];
- Y=Points[i*3+1];
- Z=Points[i*3+2];
-
- /* rotate on x-axis */
- Yt=(Y*a_cos(Xan)-Z*a_sin(Xan)) >> NUMB;
- Zt=(Y*a_sin(Xan)+Z*a_cos(Xan)) >> NUMB;
- Y=Yt;
- Z=Zt;
-
- /* rotate on y-axis */
- Xt=(X*a_cos(Yan)-Z*a_sin(Yan)) >> NUMB;
- Zt=(X*a_sin(Yan)+Z*a_cos(Yan)) >> NUMB;
- X=Xt;
- Z=Zt;
-
- /* rotate on y-axis */
- Xt=(X*a_cos(Zan)-Y*a_sin(Zan)) >> NUMB;
- Yt=(X*a_sin(Zan)+Y*a_cos(Zan)) >> NUMB;
- X=Xt;
- Y=Yt;
-
- X=X+Xtv;
- Y=Y+Ytv;
- Z=Z+Ztv;
-
- ScreenX=((X+PreXadd)<<8)/(Z+PreZadd)+PostXadd;
- ScreenY=((Y+PreYadd)<<8)/(Z+PreZadd)+PostYadd;
-
- ThisDI=ScreenY*ScreenWidth+ScreenX;
-
- if (SaveDI[i] != -1)
- {
- _DI=SaveDI[i];
-
- asm mov al,0
- asm mov es:[di],al
-
- SaveDI[i]=-1;
- }
-
- if (ScreenX<0 || ScreenX>ScreenWidth-1) continue;
- if (ScreenY<0 || ScreenY>ScreenHeight-1) continue;
-
- _DI=ThisDI;
-
- asm mov al,15
- asm mov es:[di],al
-
- SaveDI[i]=ThisDI;
- }
-
- asm mov ah,1
- asm int 16h
- asm jz nokey
-
- switch(getch())
- {
- case '\x1b':
- done=1;
- break;
- }
-
- nokey:
-
- Waited++;
- if (Waited>3)
- {
- PostXadd-=(a_sin(PostXadd-ScreenWidth/2)*10)/256;
- if (PostXadd<ScreenWidth/2)
- PostXadd=ScreenWidth/2;
- if (PreZadd<-313)
- PreZadd+=(PreZadd/-313*45);
- if (PreZadd>-313) PreZadd=-313;
-
- Xan=Xan+Xi;
- Yan=Yan+Yi;
- Zan=Zan+Zi;
-
- if (Xan<0) { Xan=359; }
- if (Yan<0) { Yan=359; }
- if (Zan<0) { Zan=359; }
-
- if (Xan>359) { Xan=0; }
- if (Yan>359) { Yan=0; }
- if (Zan>359) { Zan=0; }
-
- Waited=0;
- }
-
- /* keep it about the same on all systems */
- delay(1);
- }
-
- asm mov ax,03h
- asm int 10h
-
- asm mov ah,9
- asm mov dx,offset text
- asm int 21h
-
- return 0;
- }
-
-